# 
# Created with PyCharm.
# Description :
# User: jiume
# Date: 2024-10-16
# Time: 20:52
#
from operator import irshift

# # 创建元组
# # 使用()创建元组
# t1 = (1,'Hello',[1,2,3])
# print(t1) # 输出为 (1, 'Hello', [1, 2, 3])
#
# # 使用内置函数tuple创建元组
# t2 = tuple('Hello') # 字符串是序列
# print(t2) # 输出为 ('H', 'e', 'l', 'l', 'o')
#
# t3 = tuple([10,'Hello']) # 列表是序列
# print(t3) # 输出为 (10, 'Hello')
#
# t = (3)
# print(type(t)) # 输出为 <class 'int'> ——> 整型
#
# t = (3,)
# print(type(t)) # 输出为 <class 'tuple'> ——> 元组类型

# # 遍历元组
# t =  ('Hello', 'Python',123)
# for item in t:
#     print(item, end=' ') # 输出为 Hello Python 123
# print()
#
# t =  ('Hello', 'Python',123)
# for i in range(0,len(t)):
#     print(t[i],end=' ') # 输出为 Hello Python 123
# print()

# t = ('Hello', 'Python',123)
# for index,item in enumerate(t, 1):
# print(index,item)

# # 元组生成式
# t = (i for i in range(1,4))
# print(t)

# # 转换为列表
# l = list(t)
# print(l)
#
# # 转换为元组
# t = tuple(t)
# print(t)

# for item in t:
#     print(item,end=' ') # 输出为 1 2 3

# print(t.__next__()) # 输出为 1
# print(t.__next__()) # 输出为 2
# print(t.__next__()) # 输出为 3

# # 字典的创建
# # 使用{}方式创建
# d = {1:'Hello',2:'World',3:'Python'}
# print(d)
#
# # 当键冲突时，前面的值会被覆盖
# d = {1:'Hello',2:'World',3:'Python',3:'Java'}
# print(d)
#
# # 使用dict()创建
# d = dict(Hello=1,Python=2) # 这里的Hello会被当作字符串，作为键
# print(d)
# # 不能直接将数字字面值作为键
# # d = dict(1=Hello,2=Python) ——> error
#
# # 使用zip函数创建字典
# z = zip([1,2,3],['Hello','Python','Java'])
# # z = zip((1,2),('Hello','World'))
# # z = zip(([1,2],[3,4]),('Hello','World'))
# print(z) # 这里也是生成的zip对象
#
# # zip对象需要转换为列表、元组、字典才行,同样只能这个对象只能使用一次
# # print(list(z))
# # print(tuple(z))
# print(dict(z))

# d = {1:'Hello',2:'World',3:'Python'}
# print(d[1]) # 输出为 Hello
# print(d.get(3)) # 输出为 Python

# d = {1:'Hello',2:'World',3:'Python'}
# for element in d.items():
#     print(element,end=' ') # 输出为 (1, 'Hello') (2, 'World') (3, 'Python')
# print()
#
# for key,value in d.items():
#     print(key,'-->',value)
# # 输出为
# # 1 --> Hello
# # 2 --> World
# # 3 --> Python

# d = {1:'Hello',2:'World',3:'Python'}
# # d = {'Python':1}
# # print(d["java"])
# print(d.get("Java",[1,2,3])) # 默认值可以随便设置